tools/ocaml/xenstored: Check for maxrequests before performing operations
authorEdwin Török <edvin.torok@citrix.com>
Thu, 28 Jul 2022 16:08:15 +0000 (17:08 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 1 Nov 2022 14:07:24 +0000 (14:07 +0000)
commitab21bb1971a7fa9308053b0686f43277f6e8a6c9
treeed6d586e3985391683f31ac5a2052c9ba4a6e87c
parentb0e95b451225de4db99bbe0b8dc79fdf08873e9e
tools/ocaml/xenstored: Check for maxrequests before performing operations

Previously we'd perform the operation, record the updated tree in the
transaction record, then try to insert a watchop path and the reply packet.

If we exceeded max requests we would've returned EQUOTA, but still:
* have performed the operation on the transaction's tree
* have recorded the watchop, making this queue effectively unbounded

It is better if we check whether we'd have room to store the operation before
performing the transaction, and raise EQUOTA there.  Then the transaction
record won't grow.

This is part of XSA-326 / CVE-2022-42317.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
(cherry picked from commit 329f4d1a6535c6c5a34025ca0d03fc5c7228fcff)
tools/ocaml/xenstored/process.ml
tools/ocaml/xenstored/transaction.ml